(function() {
    angular.module('BlurAdmin.pages.SystemSettings')
        .controller('dsfCtrl', dsfCtrl);

    function dsfCtrl($scope, baConfig, $http, $myconfig) {




        //拖动效果
        $scope.transparent = baConfig.theme.blur;
        var dashboardColors = baConfig.colors.dashboard;
        var colors = [];
        for (var key in dashboardColors) {
            colors.push(dashboardColors[key]);
        }

        function getRandomColor() {
            var i = Math.floor(Math.random() * (colors.length - 1));
            return colors[i];
        }

        //获取系统信息
        $http.get($myconfig.api.app_list_APP).then(function(res) {
            if (res.data.success) {
                console.log(res);
                $scope.thirdpartyapp = res.data.data.thirdpartyapp; //第三方应用信息
            }

        });


        $scope.todoList_data = {
            logo: "",
            name: "",
            iosurl: "",
            androidurl: ""
        }

        $scope.todoList = [{
                logo: 'http://avatar.csdn.net/F/1/D/1_u014421556.jpg',
                name: '金鼻光应用',
                iosurl: 'www.oooo.com---ops',
                androidurl: 'www.oooo.androidurl'
            },
            {
                logo: 'http://avatar.csdn.net/F/1/D/1_u014421556.jpg',
                name: '金鼻光666',
                iosurl: 'www.oooo.com---ops',
                androidurl: 'www.oooo.androidurl'
            }, {
                logo: 'http://avatar.csdn.net/F/1/D/1_u014421556.jpg',
                name: '金鼻999',
                iosurl: 'www.oooo.com---ops',
                androidurl: 'www.oooo.androidurl'
            },
        ];
        //点击发送修改信息
        $scope.modify = function(val) {
            var opt = {};
            opt.thirdpartyapp = $scope.todoList;
            $http.post($myconfig.api.app_update_APP, opt).then(function(res) {
                if (res.data.success) {
                    $mydialog.success('设置成功');
                    $scope.myopen.opt_close();
                } else {
                    $mydialog.fail(res.data.data)
                }
            });
        };

        $scope.$watch('todoList', function(newValue, oldValue) {
            console.log(123);
        }, true);

        $scope.todoList.forEach(function(item) {
            item.color = getRandomColor();
        });

        $scope.newTodoText = '';

        $scope.addToDoItem = function(event, clickPlus) {
            if (clickPlus || event.which === 13) {
                $scope.todoList.unshift({
                    text: $scope.newTodoText,
                    color: getRandomColor(),
                });
                $scope.newTodoText = '';
            }
        };


    }
})();